package com.st.buy.content.controller;

import com.st.buy.content.service.ContentService;
import com.st.buy.pojo.TbContent;
import com.st.buy.util.pojo.BuyResult;
import com.st.buy.util.pojo.EasyUIDatagrideVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 张双虎
 */
@RestController
public class ContentContrller {

    @Autowired
    private ContentService contentService;

    @RequestMapping("/content/queryByCid/{cid}")
    public List<TbContent> queryByCid(@PathVariable long cid){
        return contentService.queryByCid(cid);
    }

    @RequestMapping("/content/save")
    public BuyResult save(@RequestBody TbContent content){
        return contentService.save(content);
    }

    @RequestMapping("/content/list")
    @ResponseBody
    public EasyUIDatagrideVO<TbContent> queryList(@RequestParam(defaultValue = "1") long page, @RequestParam(defaultValue = "20") long rows, long categoryId){
        return contentService.queryByCid(categoryId,page,rows);
    }
}
